package com.example.json;


import com.example.pojo.Person;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;


// 接受 json 数据
@RequestMapping("json")
@Controller
@ResponseBody
public class JsonController {


    /**
     * @RequestBody 代表接收 json 数据（默认接受 param 参数，所以必须加注解）
     *
     */
    @PostMapping(path = "data")
    public String data(@RequestBody Person person) {
        System.out.println("Person:" + person);
        return person.toString();
    }


}